home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / cooles1a / ontop.bas < prev   
BASIC Source File  |  1998-12-03  |  814b  |  26 lines

  1. Attribute VB_Name = "Proger"
  2. Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
  3. Public Const HWND_NOTOPMOST = -2
  4. Public Const HWND_TOPMOST = -1
  5. Public Const SWP_NOMOVE = &H2
  6. Public Const SWP_NOSIZE = &H1
  7. Public Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
  8.  
  9.  
  10. Public Sub Ontop(FormName As Form)
  11.     Call SetWindowPos(FormName.hwnd, HWND_TOPMOST, 0&, 0&, 0&, 0&, FLAGS)
  12. End Sub
  13. Public Sub Notontop(FormName As Form)
  14.     Call SetWindowPos(FormName.hwnd, HWND_NOTOPMOST, 0&, 0&, 0&, 0&, FLAGS)
  15. End Sub
  16.  
  17. 'to use this all you have to do is call the sub in a command
  18. 'button or form load
  19. 'to stay on top use
  20.  
  21. 'Ontop me
  22.  
  23. 'to stop that use
  24.  
  25. 'Notontop Me
  26.